package com.baizhi.stringx;

import java.util.Arrays;

/**
 * String常用方法四
 */
public class StringDemo6 {
    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "ABC";

        System.out.println(s1.equals(s2)); //false
        /*
         boolean equalsIgnoreCase()
         忽略大小写验证是否相同
         */
        System.out.println(s1.equalsIgnoreCase(s2));//true


        String str = "abcdefg";
        /*
         char[] toCharArray()
         把字符串转换成char数组
         */
        char[] chars = str.toCharArray();
        System.out.println(Arrays.toString(chars));

        String  s3 = "我爱Java,学习Java就是为了找一个好工作";
        /*
            String replace(String str,String s)
            以s替换str中指定的内容
         */
        s3 = s3.replace("找一个好工作", "改变世界");
        System.out.println(s3);


        String s4 = "abc,def,hig,klm,nop";
        /*
            String[] split(String regex)
            根据regex拆分字符串，拆分成字符串数组
         */
        String[] split = s4.split(",");
        System.out.println(Arrays.toString(split));

        String s5 = "abc123def456hig789klm";
        String[] split1 = s4.split("[0-9]");
        System.out.println(Arrays.toString(split1));



    }
}
